<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class CreateKeywordsTable extends Migration
{
    public function up()
    {
        Schema::create('keywords', function (Blueprint $table) {
            $table->increments('id');

            $table->unsignedInteger('user_id')->default(0)->comment('用户ID');
            $table->unsignedInteger('tag_id')->default(0)->comment('标签ID');
            $table->unsignedInteger('keyword_id')->default(0)->comment('关键词ID，来自Java');
            $table->string('keyword')->default('')->comment('关键词');
            $table->timestamp('used_at')->nullable()->comment('使用时间，如果为null则表示未被使用');
            $table->unsignedInteger('operator_keyid')->default(0)->comment('Java给的，原样保存');

            $table->timestamps();

            $table->index('user_id');
            $table->index('tag_id');
        });
    }

    public function down()
    {
        Schema::dropIfExists('keywords');
    }
}
